#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 1e6 + 5;
int T, n, m, l, V, c, d[N], v[N], a[N], p[N], q[M], z[M], y[M], ans[25], ac, max0, max2;
double x(int vx, int ax){
    return (double)((double)(V * V-vx * vx)/(double)(2*ax));
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while(T--){
        c = 0;
        bool flag1 = 1;
        int cnt = 0;
        memset(q, 0, sizeof(q));
        cin >> n >> m >> l >> V;
        for(int i = 1; i <= n; i++){
            //scanf("%d%d%d", &d[i], &v[i], &a[i]);
            cin >> d[i] >> v[i] >> a[i];
            if(a[i] < 0) flag1 = 0;
        }
        for(int i = 1; i <= m; i++){
            cin >> p[i];
        }
        for(int i = 1; i <= m; i++){
            q[p[i]] = i;
        }
        for(int i = 1; i <= n; i++){
            if(a[i] == 0){
                if(v[i] > V && d[i] <= p[m]){
                    c++;
                }
            }else if(a[i] > 0){
                if(v[i] <= V){
                    if(d[i] + x(v[i], a[i]) < p[m]){
                        c++;
                    }
                }else if(d[i] <= p[m]){
                    c++;
                }
            }else if(v[i] > V){
                int E = d[i] + x(v[i], a[i]);
                for(int j = d[i]; j <= E; j++){
                    if(q[j]){
                        c++;
                        break;
                    }
                }
            }
        }
        if(c)
        cout << c << " " << m - 1 << endl;
        else cout << c << " " << m << endl;
    }
    return 0;
}
